package top.kaoshanji.p1ch02c;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import top.kaoshanji.p1ch02c.config.ProjectConfig;
import top.kaoshanji.p1ch02c.main.Parrot;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/4/27 16:00
 */
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { ProjectConfig.class })
public class AppTests {

    @Autowired
    private ApplicationContext context;

    /**
     * 代码清单test-p1ch02c-16页a：测试一下通用注解定义Bean
     */
    @Test
    public void testParrotWasAdded() {
        Parrot parrot = context.getBean(Parrot.class);

        Assertions.assertNotNull(parrot);
        Assertions.assertNull(parrot.getName());

    }

}
